package xyz.robinbingo.leetcode.a20.b07.c02;

import java.util.Arrays;

public class Solution {
    public int kthSmallest(int[][] matrix, int k) {
        int[] ints = new int[matrix.length * matrix[0].length];
        int l = 0;
        for (int[] value : matrix) {
            for (int j = 0; j < matrix[0].length; j++) {
                ints[l++] = value[j];
            }
        }
        Arrays.sort(ints);
        return ints[k - 1];
    }
}